<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>循环遍历</title>
    <style>
        [v-cloak]{
            display: none;
        }
    </style>
</head>
<body>
    <div id="app" >

        <!-- 没有使用下标值 -->
        <ul>
            <li v-for="value in names">{{value}}
                <input type="checkbox">
            </li>
        </ul>

            <!-- 使用key提高性能,不用index，用index没效果 -->
        <ul>
            <li v-for="(value,index) in names" :key="value">{{value}}
                <input type="checkbox">
            </li>
        </ul>

        <button @click="editnames">修改名字数组</button>

        <!-- 使用下标值 -->
        <ul>
            <li v-for="(value,index) in names">{{index+'--'+value}}</li>
        </ul>

        <!-- 遍历对象 -->
        <ul>
            <li v-for="value in info">{{value}}</li>
        </ul>

        <ul>
            <li v-for="(value,key) in info">{{key+'---'+value}}</li>
        </ul>

        <ul>
            <li v-for="(value,key,index) in info">{{index+':'+key+'---'+value}}</li>
        </ul>






    </div>
    <script src="./vue.js"></script>
    <script>
       let app=new Vue({
            el:"#app",
            data:{
                names:['aaa','bbb','ccc'],
                info:{
                    name:"张三",
                    age:13,
                    height:1.89
                }

            },
            methods: {
                editnames(){
                    // vue.set(数组，修改下标，修改值)
                    Vue.set(this.names,0,'pppp')
                }
            },
        })
        
    </script>
</body>
</html>